﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class add_table_BizDict : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainDataDict_MainCatgeDict_DataCatgeId",
                table: "MainDataDict");

            migrationBuilder.DropIndex(
                name: "IX_MainDataDict_DataCatgeId",
                table: "MainDataDict");

            migrationBuilder.DropColumn(
                name: "DataCatgeId",
                table: "MainDataDict");

            migrationBuilder.AddColumn<string>(
                name: "CatgeCodg",
                table: "MainDataDict",
                type: "text",
                nullable: false,
                defaultValue: "");

            migrationBuilder.CreateTable(
                name: "MainBizDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    BizDictCodg = table.Column<string>(type: "text", nullable: false),
                    BizDictName = table.Column<string>(type: "text", nullable: false),
                    SrtNo = table.Column<int>(type: "integer", nullable: false),
                    CatgeCodg = table.Column<string>(type: "text", nullable: false),
                    DataDictCode = table.Column<string>(type: "text", nullable: true),
                    DataDictName = table.Column<string>(type: "text", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainBizDict", x => x.Id);
                });
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MainBizDict");

            migrationBuilder.DropColumn(
                name: "CatgeCodg",
                table: "MainDataDict");

            migrationBuilder.AddColumn<Guid>(
                name: "DataCatgeId",
                table: "MainDataDict",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.CreateIndex(
                name: "IX_MainDataDict_DataCatgeId",
                table: "MainDataDict",
                column: "DataCatgeId");

            migrationBuilder.AddForeignKey(
                name: "FK_MainDataDict_MainCatgeDict_DataCatgeId",
                table: "MainDataDict",
                column: "DataCatgeId",
                principalTable: "MainCatgeDict",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
